from ochumanApi.ochuman import OCHuman
# <Filter>:
#      None(default): load all. each has a bbox. some instances have keypoint and some have mask annotations.
#            images: 5081, instances: 13360
#     'kpt&segm' or 'segm&kpt': only load instances contained both keypoint and mask annotations (and bbox)
#            images: 4731, instances: 8110
#     'kpt|segm' or 'segm|kpt': load instances contained either keypoint or mask annotations (and bbox)
#            images: 5081, instances: 10375
#     'kpt' or 'segm': load instances contained particular kind of annotations (and bbox)
#            images: 5081/4731, instances: 10375/8110
# ochuman = OCHuman(AnnoFile='/root/data/OCHuman/ochuman.json', Filter='kpt&segm')
# ochuman = OCHuman(AnnoFile='/root/data/OCHuman/ochuman.json', Filter='segm')
ochuman = OCHuman(AnnoFile='/root/data/OCHuman/ochuman.json', Filter=None)
image_ids = ochuman.getImgIds()
print ('Total images: %d'%len(image_ids))

## Convert to coco format.
# <maxIouRange>:
#     (0.0, 1.0) means all instances
#     (0.5, 0.75) means Moderate instances
#     (0.75, 1.0) means Hard instances
ochuman.toCocoFormatNoKpt(subset='all', maxIouRange=(0.0, 1.0), save_dir='/root/data/OCHuman/')
